units icon

units

(0 reviews)

API REST

DEFINICIΓ“N

REST APIs use Uniform Resource Identifiers (URI) to address resources. Properly done URIs layouts would clearly communicate the API resource, such as:

http://example.restapi.es/france/paris/louvre/leonardo-da-vinci/mona-lisa

An incorrect design of URIs would give a much more difficult resource to understand like:

http://example.restapi.es/68dd0-a9d3-11e0-9f1c-0800200c9a66

The information in each section, when we are talking about REST, are the resources. Therefore it is the information that we want to access, modify or delete, which we can only do through the first URI example shown.


FORMATO DE URI

The generic URI syntax is defined as follows:

URI = scheme "://" authority "/" path [ "?" query ] [ "#" fragment ]
resources/image-9b091ecf-c746-406f-8a00-8dade9dd1156.png

Endpoint example with the URI standard

β€’ URI Scheme: The scheme identifies the protocol to access the resources, it can be HTTP (without SSL) or HTTPS (with SSL). It is made up of the name of the scheme followed by a colon (β€œ:”).

β€’ Authority: It is the hierarchical element that identifies the naming authority, it is form by the hostname and the port.

β€’ Hostname: It is the identifier of a machine within a network which identifies the host that contains the resource.

β€’ Port: It is an optional value which specifies the port on whereby the host listens for requests, the default port of a web server is 80.

β€’ Path: It is the route that identifies the resource specific on the host which the consuming client wants to access, separating the hierarchical structure of resources with a slash (β€œ/”)

β€’ Section: In the logical hierarchy of resources this would be the parent resource

β€’ Sub-section: It is a resource child, directly related with a father resouce

β€’ Query: It is an optional component that is included after the path and has a non-hierarchical structure, and provides a string of information that the resource can use for some purpose, for example, to search parameters or data to be processed. The query is usually a string of pairs of parameters and values ("argument=value"). The arguments along with the values are separated from each other by an ampersand ("&")

β€’ Arguments: They are the parameters that will be used in the query, they must go immediately after the path and start with a question mark (β€œ?”)

β€’ Values: They are the values that contain the parameters of the query

β€’ Fragment: The fragment is an optional component that allows you to identify a part of the main resource, or view of a representation of it. The beginning of this component is indicated by the pound character (β€œ#”)


Reviews